package http

import (
	"ginfwk/adapter/repository_impl"
	"ginfwk/framework/core/gins"
	"ginfwk/framework/kernel"
	"github.com/gin-gonic/gin"
	di "github.com/samber/do"
)

type AppKernel struct {
	kernel.GHttpKernel
}

func (app *AppKernel) Middlewares() []gin.HandlerFunc {
	return app.GHttpKernel.Middlewares()
}

func (app *AppKernel) Providers() []kernel.Provider {
	return append(
		app.GHttpKernel.Providers(),
		RouterRegisterProvider,
		repository_impl.AppRepositoryProvider,
	)
}

// RouterRegisterProvider 注册httpRouter
func RouterRegisterProvider() {
	di.Provide[gins.RouterRegister](nil, func(injector *di.Injector) (gins.RouterRegister, error) {
		return new(HttpRouter), nil
	})
}
